package com.sangeng.service.impl;

import com.sangeng.dao.AccoutDao;
import com.sangeng.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccoutDao accoutDao;

    @Override
    @Transactional(propagation = Propagation.REQUIRES_NEW)
    public void transfer(Integer outId, Integer inId, Double money) {
        accoutDao.updateMoney(inId, money);
        accoutDao.updateMoney(outId, -money);
    }

    @Override
    public void log() {
        System.out.println("打印日志");
        int i =1/0;
    }
}
